home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
TUTORIAL
/
1307B.ZIP
/
ANSWERS
/
CH05E2.MOD
< prev
next >
Wrap
Text File
|
1989-01-18
|
1KB
|
50 lines
(* Chapter 5 - Programming exercise 2 *)
(* Chapter 5 - Program 7 *)
MODULE CH05E2;
FROM InOut IMPORT WriteString, WriteInt, WriteLn;
VAR Count : INTEGER;
PROCEDURE PrintAndDecrement(Index : INTEGER);
BEGIN
WriteString("The value of the Index is");
WriteInt(Index,5);
WriteLn;
Index := Index - 1;
IF Index > 0 THEN
PrintAndDecrement(Index);
END;
WriteString("The value of the Index is");
WriteInt(Index,5);
WriteLn;
END PrintAndDecrement;
BEGIN (* Main program *)
Count := 7;
PrintAndDecrement(Count);
END CH05E2.
(* Result of execution
The value of the Index is 7
The value of the Index is 6
The value of the Index is 5
The value of the Index is 4
The value of the Index is 3
The value of the Index is 2
The value of the Index is 1
The value of the Index is 0
The value of the Index is 1
The value of the Index is 2
The value of the Index is 3
The value of the Index is 4
The value of the Index is 5
The value of the Index is 6
*)